package myGradleProject;

import lombok.Builder;
import lombok.ToString;
@Builder
@ToString
public class PreminumCaculator {
    private int age,child;
    private char sex;
    private String ms;
    public int getAgePoint() throws PreminumCaculatorException {
        if(age>=1&&age<20) {
            return 2;
        }
        else if(age<=39) {
            return 6;
        }
        else if (age<=59) {
            return 4;
        }
        else if(age<99) {
            return 2;
        }
        else
            throw new PreminumCaculatorException("年龄参数不正确");
    }
    public int getSexPoint() throws PreminumCaculatorException {
        if(sex=='F'||sex=='f') {
            return 3;
        }
        else if(sex=='M'||sex=='m') {
            return 4;
        }
        else
            throw new PreminumCaculatorException("性别参数不正确");
    }
    public int getMSPoint() throws PreminumCaculatorException {
        if (ms=="已婚") {
            return 3;
        }
        else if (ms=="未婚") {
            return 5;
        }
        else
            throw new PreminumCaculatorException("婚姻状况参数不正确");
    }
    public double getChildPoint() throws PreminumCaculatorException {
        if(child>0&&child<=10) {
            return -0.5*child;
        }
        else
            throw new PreminumCaculatorException("抚养人数参数不正确");
    }
}